﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using VOL.Core.Utilities;
using VOL.Domain.IServices;
using VOL.Domain.Dto.QualityManagement;
using VOL.Core.Filters;
using VOL.Entity.DomainModels;

namespace VOL.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class QualityManagementController : ControllerBase
    {
        private readonly IInspectionSheetService _inspectionSheetService;

        public QualityManagementController(IInspectionSheetService inspectionSheetService)
        {
            _inspectionSheetService = inspectionSheetService;
        }

        /// <summary>
        /// 获取检验单分页列表数据
        /// </summary>
        /// <param name="queryDTO">查询条件</param>
        /// <returns>返回检验单列表数据</returns>
        [HttpGet]
        public  Task<WebResponseContent> GetInspectionSheetPageData([FromQuery] InspectionSheetQueryDTO queryDTO)
        {
            return  _inspectionSheetService.GetInspectionSheetPageData(queryDTO);
        }

        /// <summary>
        /// 新增检验单
        /// </summary>
        /// <param name="inspectionSheet">检验单实体</param>
        /// <returns>返回新增结果</returns>
        [HttpPost]
        public async Task<WebResponseContent> AddInspectionSheet([FromBody] InspectionSheet inspectionSheet)
        {
            return await _inspectionSheetService.AddInspectionSheet(inspectionSheet);
        }

        /// <summary>
        /// 修改检验单
        /// </summary>
        /// <param name="inspectionSheet">检验单实体</param>
        /// <returns>返回修改结果</returns>
        [HttpPost]
        public async Task<WebResponseContent> UpdateInspectionSheet([FromBody] InspectionSheet inspectionSheet)
        {
            return await _inspectionSheetService.UpdateInspectionSheet(inspectionSheet);
        }

        /// <summary>
        /// 批量删除检验单
        /// </summary>
        /// <param name="ids">检验单ID集合</param>
        /// <returns>返回删除结果</returns>
        [HttpPost]
        public async Task<WebResponseContent> DeleteInspectionSheet([FromBody] int[] ids)
        {
            return await _inspectionSheetService.DeleteInspectionSheet(ids);
        }
    }
}
